<template>
	<view>
		<!-- 选择器 -->
		<view>
			<u-button @click="showChoose = true" v-text="keyword?keyword:'选择发布类型'"></u-button>
		</view>
		
		<view v-if="keyword" style="margin: 20rpx;padding: 30rpx;border-radius: 20rpx;background-color: white;">
			<!-- 社会资讯 -->
			<view v-if="keyword == '社会资讯'">
				<u-form labelPosition="left" :model="societyData" :rules="societyRules" ref="uForm">
					<u-form-item label="标题" prop="title" borderBottom ref="item1">
						<u--input v-model="societyData.title" border="none" placeholder="请输入标题"></u--input>
					</u-form-item>
					<u-form-item label="地点" prop="address" borderBottom ref="item1">
						<u--input v-model="societyData.address" placeholder="某镇某路段" border="none"></u--input>
					</u-form-item>
					<u-form-item label="时间" prop="newTime" borderBottom @click="showTime = true; hideKeyboard()">
						<u--input v-model="societyData.newTime" disabled disabledColor="#ffffff" placeholder="请选择时间"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="内容" prop="content">
						<template>
							<u--textarea v-model="societyData.content" placeholder="请输入内容" count></u--textarea>
						</template>
			
					</u-form-item>
					<u-form-item label="图片" prop="societyData.newPic">
						<template>
							<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
								:previewFullImage="true" :max-size="2 * 1024 * 1024" @oversize="oversize"
								:auto-upload="false" :maxCount="6"></u-upload>
						</template>
					</u-form-item>
			
				</u-form>
				<view class="btn—submit">
					<button @click="submitSociety">提交</button>
				</view>
			</view>
			
			
			<!-- 推荐店铺 -->
			<view v-if="keyword == '推荐店铺'" style="flex-direction: column;display: flex;justify-content: center;align-items: center;">
<!-- 				<view>
					<image src="../../static/weChatCode.jpg" @click="click" mode="widthFix"></image>
				</view> -->
				<view>
					<text> 发布店铺信息，请扫码以上微信或手动添加微信号：18154741783</text>
					<u-button type="primary" :plain="true" :hairline="true" text="复制微信号" @click="copy"></u-button>
				</view>
			</view>
			
			
			
			<!-- 求职 -->
			<view class="job-hunt" v-if="keyword == '求职'">
				<u--form labelPosition="left" labelWidth="auto" :model="jobHuntData" :rules="jobHuntRules"
					ref="jobHuntForm">
					<u-form-item label="姓名" prop="username" borderBottom>
						<u--input v-model="jobHuntData.username" border="none" style="padding-left: 10rpx;"
							placeholder="请输入姓名"></u--input>
					</u-form-item>
					<u-form-item label="性别" prop="sex" borderBottom @click="showSex = true; hideKeyboard()">
						<u--input v-model="jobHuntData.sex" disabled disabledColor="#ffffff" placeholder="请选择性别"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="联系电话" prop="phoneNum" borderBottom>
						<u--input v-model="jobHuntData.phoneNum" border="none" maxLe placeholder="请输入联系电话"
							type="number"></u--input>
					</u-form-item>
					<u-form-item label="求职岗位" prop="job" borderBottom>
						<u--input v-model="jobHuntData.job" border="none" placeholder="请输入意向岗位"></u--input>
					</u-form-item>
					<u-form-item label="求职状态" prop="jobStatus" borderBottom
						@click="showJobStatusShow = true; hideKeyboard()">
						<u--input v-model="jobHuntData.jobStatus" disabled disabledColor="#ffffff" placeholder="请选择求职状态"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="期望办公地区" prop="workLocation" borderBottom
						@click="showAddress = true; hideKeyboard()">
						<u--input v-model="jobHuntData.workLocation" disabled disabledColor="#ffffff" placeholder="请选择办公区域"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="期望薪资" prop="salary" borderBottom>
						<u--input v-model="jobHuntData.salary" placeholder="请输入期望薪资" border="none" type="number">
							<u--text
								text="/月"
								slot="suffix"
								margin="0 3px 0 0"
								type="tips"
							></u--text>
						</u--input>
					</u-form-item>
					<u-form-item label="工作经验" prop="workExperience">
						<template>
							<u--textarea v-model="jobHuntData.workExperience" placeholder="请输入内容" count></u--textarea>
						</template>
					</u-form-item>
			
				</u--form>
				<view class="btn—submit">
					<button @click="submitJubHunt">提交</button>
				</view>
			</view>
			
			<!-- 招聘 -->
			<view v-if="keyword == '招聘'">
				<u--form labelPosition="left" labelWidth="auto" :model="recruitData" :rules="recruitRules"
					ref="recruitForm">
					<u-form-item label="职位" prop="recruitJob" borderBottom ref="item1">
						<u--input v-model="recruitData.recruitJob" border="none" style="padding-left: 10rpx;"
							placeholder="请输入职位"></u--input>
					</u-form-item>
					<u-form-item label="薪资福利" prop="recruitSalary" borderBottom ref="item1">
						<u-input placeholder="2000-10000" v-model="recruitData.recruitSalary" disabledColor="#ffffff" border="none">
							<u--text
								text="/月"
								slot="suffix"
								margin="0 3px 0 0"
								type="tips"
							></u--text>
						</u-input>
					</u-form-item>
					<u-form-item label="人数" prop="peopleNum" borderBottom ref="item1">
						<u--input v-model="recruitData.peopleNum" border="none" placeholder="例如: 1">
						<u--text
							text="人"
							slot="suffix"
							margin="0 3px 0 0"
							type="tips"
						></u--text></u--input>
					</u-form-item>
					<u-form-item label="工作地址" prop="workLocation" borderBottom ref="item1">
						<u--input v-model="recruitData.workLocation" border="none" placeholder="xx镇xx路xx号xx店"></u--input>
					</u-form-item>
					<u-form-item label="职位描述" prop="jobDescription" borderBottom ref="item1">
						<u--input v-model="recruitData.jobDescription" disabledColor="#ffffff"
							placeholder="请输入职位描述" border="none"></u--input>
					</u-form-item>
					<u-form-item label="招聘单位" prop="recruitmentUnit" borderBottom ref="item1">
						<u--input v-model="recruitData.recruitmentUnit" placeholder="请输入招聘单位" border="none"></u--input>
					</u-form-item>
					<u-form-item label="联系人" prop="recruitContacts" borderBottom ref="item1">
						<u--input v-model="recruitData.recruitContacts" placeholder="请输入联系人姓名" border="none"
							></u--input>
					</u-form-item>
					<u-form-item label="联系电话" prop="telephone" borderBottom ref="item1">
						<u--input v-model="recruitData.telephone" placeholder="请输入联系电话" border="none"
							type="number"></u--input>
					</u-form-item>
					<u-form-item label="截止时间" prop="endTime" borderBottom @click="showTime = true; hideKeyboard()">
						<u--input v-model="recruitData.endTime" disabled disabledColor="#ffffff" placeholder="请选择时间"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="要求" prop="recruitAsk">
						<template>
							<u--textarea v-model="recruitData.recruitAsk" placeholder="请输入应聘要求" count></u--textarea>
						</template>
					</u-form-item>
					
				</u--form>
				<view class="btn—submit">
					<button @click="submitRecruit">提交</button>
				</view>
			</view>
			
			
			<!-- 房屋租售 -->
			<view v-if="keyword == '房屋租售'">
				<u--form labelPosition="left" labelWidth="auto" :model="houseSellData" :rules="houseSellRules"
					ref="houseSellForm">
					<u-form-item label="房屋性质" prop="houseNature" borderBottom ref="item1" @click="showHouseNature = true; hideKeyboard()">
						<u--input v-model="houseSellData.houseNature" disabled disabledColor="#ffffff" border="none" style="padding-left: 10rpx;"
							placeholder="请选择房屋性质"></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="标题" prop="houseTitle" borderBottom ref="item1">
						<u-input placeholder="请输入标题" v-model="houseSellData.houseTitle"  border="none">
						</u-input>
					</u-form-item>
					<u-form-item label="地址" prop="houseAddress" borderBottom ref="item1">
						<u--input v-model="houseSellData.houseAddress" border="none" placeholder="xx镇xx路xx号"
						></u--input>
					</u-form-item>
					<u-form-item label="房屋面积" prop="houseArea" borderBottom >
						<u-input v-model="houseSellData.houseArea" border="none" placeholder="例如:132">
							<u--text
								text="平方米"
								slot="suffix"
								margin="0 3px 0 0"
								type="tips"
							></u--text>
						</u-input>
					</u-form-item>
					<u-form-item label="户型" prop="houseType" borderBottom >
						<u--input v-model="houseSellData.houseType" 
							placeholder="例如:三房两厅一厨一卫" border="none"></u--input>
					</u-form-item>
					<u-form-item label="楼层" prop="houseHeight" borderBottom >
						<u--input v-model="houseSellData.houseHeight" placeholder="请输入楼层" border="none"></u--input>
					</u-form-item>
					<u-form-item label="朝向" prop="houseToward" borderBottom @click="showHouseToward= true; hideKeyboard()">
						<u--input v-model="houseSellData.houseToward" disable disabledColor="#ffffff" placeholder="请选择朝向" border="none"
							></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="装修类型" prop="houseMount" borderBottom @click="showHouseMount= true; hideKeyboard()">
						<u--input v-model="houseSellData.houseMount" disabled disabledColor="#ffffff" placeholder="请选择装修类型" border="none"
							type="number"></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="价格" prop="housePrice" borderBottom >
						<u-input v-model="houseSellData.housePrice" placeholder="请输入价格" border="none"
							type="number">
							<template slot="suffix">
								<text>{{houseSellData.houseNature == '出租'?'元/月':'万元'}}</text>
							</template>
						</u-input>
					</u-form-item>
					<u-form-item label="联系人" prop="contacts" borderBottom ref="item1">
						<u--input v-model="houseSellData.contacts" placeholder="请输入联系人" border="none"
							type="number"></u--input>
					</u-form-item>
					<u-form-item label="联系电话" prop="telephoneNum" borderBottom ref="item1">
						<u--input v-model="houseSellData.telephoneNum" placeholder="请输入联系电话" border="none"
							type="number"></u--input>
					</u-form-item>
					<u-form-item label="图片" prop="houseSellData.housePic">
						<template>
							<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
								:previewFullImage="true" :max-size="2 * 1024 * 1024" @oversize="oversize"
								:auto-upload="false" :maxCount="6"></u-upload>
						</template>
					</u-form-item>
				</u--form>
				<view class="btn—submit">
					<button @click="submitHouse">提交</button>
				</view>
			</view>
			
			
			
			<!-- 周末游 -->
			<view v-if="keyword == '旅行游记'">
				<u--form labelPosition="left" :model="weekendTourData" :rules="weekendTourRules" ref="weekendTourForm">
					<u-form-item label="标题" prop="title" borderBottom ref="item1">
						<u--input v-model="weekendTourData.title" border="none" placeholder="请输入标题"></u--input>
					</u-form-item>
					<u-form-item label="内容" prop="content">
						<template>
							<u--textarea v-model="weekendTourData.content" placeholder="请输入内容" count></u--textarea>
						</template>
					</u-form-item>
					<u-form-item label="地点" prop="address" borderBottom ref="item1">
						<u--input v-model="weekendTourData.address" placeholder="xx镇xx路或者xx村" border="none"></u--input>
					</u-form-item>
					</u-form-item>
					<u-form-item label="图片" prop="weekendTourData.pic">
						<template>
							<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
								:previewFullImage="true" :max-size="2 * 1024 * 1024" @oversize="oversize"
								:auto-upload="false" :maxCount="6"></u-upload>
						</template>
					</u-form-item>
			
				</u--form>
				<view class="btn—submit">
					<button @click="submitWeekendTour">提交</button>
				</view>
			</view>
			
			
			<!-- 拼车信息 -->
			<view v-if="keyword == '同城拼车'">
				<u--form labelPosition="left" labelWidth="auto" :model="carPoolData" :rules="carPoolRules"
					ref="carPoolForm">
					<u-form-item label="拼车类型" prop="carPoolType" borderBottom @click="showCarPoolType = true; hideKeyboard()">
						<u--input v-model="carPoolData.carPoolType" disabled disabledColor="#ffffff" placeholder="请选择拼车类型"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="出发地" prop="departureLocation" borderBottom >
						<u--input v-model="carPoolData.departureLocation" border="none" style="padding-left: 10rpx;"
							placeholder="请输入出发地"></u--input>
					</u-form-item>
					<u-form-item label="目的地" prop="destination" borderBottom >
						<u--input v-model="carPoolData.destination" placeholder="请选择目的地"
							border="none"></u--input>
					</u-form-item>
					<u-form-item label="出发时间" prop="setOutTime" borderBottom @click="showTime = true; hideKeyboard()">
						<u--input v-model="carPoolData.setOutTime" disabled disabledColor="#ffffff" placeholder="请选择时间"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="人数" prop="setOutNum" borderBottom >
						<u-input v-model="carPoolData.setOutNum" type="number" border="none" placeholder="请输入人数">
							<u--text
								text="人"
								slot="suffix"
								margin="0 3px 0 0"
								type="tips"
							></u--text>
						</u-input>	
					</u-form-item>
					<u-form-item label="联系电话" prop="phoneNum" borderBottom>
						<u--input v-model="carPoolData.phoneNum" border="none" placeholder="请输入联系电话"
							type="number"></u--input>
					</u-form-item>
					<u-form-item label="备注" prop="remarks" borderBottom>
						<u--input v-model="carPoolData.remarks" border="none" placeholder="备注信息"></u--input>
					</u-form-item>
				</u--form>
				<view class="btn—submit">
					<button @click="submitCarPool">提交</button>
				</view>
			</view>
			
		</view>
		<!-- 日期选择器 -->
		<u-datetime-picker :show="showTime" :value="VshowTime" mode="datetime" closeOnClickOverlay
			@confirm="showTimeConfirm" @cancel="showTimeClose" @close="showTimeClose"></u-datetime-picker>
		<!-- 性别选择器 -->
		<u-action-sheet :show="showSex" :actions="gender" title="请选择性别" @close="showSex = false" @select="sexSelect">
		</u-action-sheet>
		<!-- 发布类型选择器 -->
		<u-action-sheet :actions="list" @select="selectClick" title="选择类型" :show="showChoose"
			@close="showChoose = false"></u-action-sheet>
		<!-- 求职状态选择器 -->
		<u-action-sheet :actions="jobStatus" @select="jobStatusSelect" title="求职状态" :show="showJobStatusShow"
			@close="showJobStatusShow = false"></u-action-sheet>
		<!-- 办公区域 -->
		<u-picker :show="showAddress" :columns="columns" @confirm="showAddressConfirm"
			@cancel="showAddressClose"></u-picker>
		<!-- 房屋 性质 选择器 -->
		<u-action-sheet :show="showHouseNature" :actions="houseNature" title="请选择房屋性质" @close="showHouseNature = false" @select="houseNatureSelect">
		</u-action-sheet>
		<!-- 房屋 装修类型 选择器 -->
		<u-action-sheet :show="showHouseMount" :actions="HouseMount" title="请选择房屋朝向" @close="showHouseMount = false" @select="houseMountSelect">
		</u-action-sheet>
		<!-- 房屋 朝向 选择器 -->
		<u-action-sheet :show="showHouseToward" :actions="houseToward" title="请选择房屋朝向" @close="showHouseToward = false" @select="houseTowardSelect">
		</u-action-sheet>
		<!-- 拼车 类型 选择器 -->
		<u-action-sheet :show="showCarPoolType" :actions="CarPoolType" title="请选择类型" @close="showCarPoolType = false" @select="carPoolTypeSelect">
		</u-action-sheet>
		<u-toast ref="uToast"/>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		submitSociety,submitJubHunt,submitRecruit,submitHouse,submitWeekendTour,submitCarPool
	} from '../../config/api.js'
	export default {
		data() {
			return {
				VshowTime: Number(new Date()),
				list: [{
						name: '社会资讯'
					},
					{
						name: '推荐店铺'
					},
					{
						name: '求职'
					},
					{
						name: '招聘'
					},
					{
						name: '房屋租售'
					},
					{
						name: '旅行游记'
					},
					{
						name: '同城拼车'
					}
				],
				gender: [{
						name: '男',
						value: 1
					},
					{
						name: '女',
						value: 2
					},
				],
				houseNature:[
					{
					name:'出租'
					},{
						name:'出售'
					},
				],
				jobStatus: [{
						name: '在职'
					},
					{
						name: '离职'
					}, {
						name: '应届'
					}
				],
				houseToward:[
					{
						name:'朝东'
					},{
						name:'朝南'
					},{
						name:'朝西'
					},{
						name:'朝北'
					}
				],
				HouseMount:[
					{
						name:'精装'
					},{
						name:'简装'
					},{
						name:'毛坯'
					}
				],
				columns: [
					[
						'不限',
						'富阳镇',
						'白沙镇',
						'莲山镇',
						'古城镇',
						'福利镇',
						'麦岭镇',
						'葛坡镇',
						'城北镇',
						'朝东镇',
						'新华乡',
						'石家乡',
						'柳家乡'
					]
				],
				CarPoolType:[
					{
							name: '车找人',
							value: 1
						},
						{
							name: '人找车',
							value: 0
						},
				],
				showSex: false,
				showJobStatusShow: false,
				showChoose: false,
				workAddressShow: false,
				showTime: false,
				showAddress: false,
				showHouseNature: false,
				showHouseToward: false,
				showHouseMount:false,
				showCarPoolType:false,
				keyword: '',
				societyData: {
					title: '',
					content: ''
				},
				jobHuntData: {
					workLocation: '',
					workExperience: ''
				},
				recruitData: {
					recruitAsk: ''
				},
				houseSellData:{
					houseNature:'',
					houseTitle:'',
					houseAddress:'',
					houseArea:'',
					houseType:'',
					houseHeight:'',
					houseToward:'',
					houseMount:'',
					housePrice:'',
					contacts:'',
					telephoneNum:''
				},
				weekendTourData:{
					title:'',
					content:'',
					address:''
				},
				carPoolData:{
					departureLocation:'',
					destination: '',
					carPoolType: '',
					setOutTime: '',
					setOutNum: '',
					phoneNum: '',
					remarks: ''
				},
				phone: '18177477706',
				fileList1: [], // 多张图片
				sizeType: ['compressed'],
				societyRules: {
					'title': {
						type: 'string',
						required: true,
						message: '请填写标题',
						trigger: ['blur']
					},
					'content': {
						type: 'string',
						required: true,
						message: '请填写内容',
						trigger: ['blur']
					},
					'address': {
						type: 'string',
						required: true,
						message: '请填写地址',
						trigger: ['blur']
					},
					'newTime': {
						required: true,
						message: '请选择时间',
						trigger: ['blur']
					}
				},
				jobHuntRules: {
					'username': {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur']
					},
					'sex': {
						type: 'string',
						required: true,
						message: '请选择性别',
						trigger: ['blur']
					},
					'phoneNum':[{
						type: 'string',
						required: true,
						message: '请填写电话号码',
						trigger: ['blur']
					},{
						max:11,
						min:11,
						message: '请输入11位手机号',
						trigger: 'blur'
					}],
					'jobStatus': {
						type: 'string',
						required: true,
						message: '请选择求职状态',
						trigger: ['blur']
					},
					'salary': {
						type: 'string',
						required: true,
						message: '请填写薪资',
						trigger: ['blur']
					},
					'workLocation': {
						type: 'string',
						required: true,
						message: '请选择办公区域',
						trigger: ['blur']
					},
					'workExperience': {
						type: 'string',
						required: true,
						message: '请填写工作经验',
						trigger: ['blur']
					},
				},
				recruitRules: { // 招聘
					'recruitJob': {
						type: 'string',
						required: true,
						message: '请填写职位',
						trigger: ['blur']
					},
					'recruitSalary': {
						type: 'string',
						required: true,
						message: '2000-10000/月',
						trigger: ['blur']
					},
					'peopleNum': {
						type: 'string',
						required: true,
						message: '请选择人数',
						trigger: ['blur']
					},
					'workLocation': {
						type: 'string',
						required: true,
						message: '请选择工作地址',
						trigger: ['blur']
					},
					'jobDescription': {
						type: 'string',
						required: true,
						message: '请填写职位描述',
						trigger: ['blur']
					},
					'recruitmentUnit': {
						type: 'string',
						required: true,
						message: '请填写招聘单位',
						trigger: ['blur']
					},
					'recruitContacts': {
						type: 'string',
						required: true,
						message: '请填写联系人',
						trigger: ['blur']
					},
					'telephone': [{
						type: 'string',
						required: true,
						message: '请填写电话号码',
						trigger: ['blur']
					},{
						max:11,
						min:11,
						message: '请输入11位手机号',
						trigger: 'blur'
					}],
					'recruitAsk': {
						type: 'string',
						required: true,
						message: '请填写应聘要求',
						trigger: ['blur']
					},
					'endTime': {
						required: true,
						message: '请选择时间',
						trigger: ['blur']
					}
				},
				houseSellRules:{ // 房屋
					'houseNature': {
						type: 'string',
						required: true,
						message: '请选择房屋性质',
						trigger: ['blur']
					},
					'houseTitle': {
						type: 'string',
						required: true,
						message: '请输入标题',
						trigger: ['blur']
					},
					'houseAddress': {
						type: 'string',
						required: true,
						message: '请输入地址',
						trigger: ['blur']
					},
					'houseArea': {
						type: 'string',
						required: true,
						message: '请输入面积',
						trigger: ['blur']
					},
					'houseType': {
						type: 'string',
						required: true,
						message: '请输入面积',
						trigger: ['blur']
					},
					'houseHeight': {
						type: 'string',
						required: true,
						message: '请输入楼层',
						trigger: ['blur']
					},
					'houseToward': {
						type: 'string',
						required: true,
						message: '请选择朝向',
						trigger: ['blur']
					},
					'houseMount': {
						type: 'string',
						required: true,
						message: '请选择装修类型',
						trigger: ['blur','change']
					},
					'housePrice': {
						type: 'string',
						required: true,
						message: '请输入价格',
						trigger: ['blur']
					},
					'contacts': {
						type: 'string',
						required: true,
						message: '请输入联系人',
						trigger: ['blur']
					},
					'telephoneNum': [{
						type: 'string',
						required: true,
						message: '请填写电话号码',
						trigger: ['blur']
					},{
						max:11,
						min:11,
						message: '请输入11位手机号',
						trigger: 'blur'
					}]
				},
				weekendTourRules: {
					'title': {
						type: 'string',
						required: true,
						message: '请填写标题',
						trigger: ['blur']
					},
					'content': {
						type: 'string',
						required: true,
						message: '请填写内容',
						trigger: ['blur']
					},
					'address': {
						type: 'string',
						required: true,
						message: '请填写地址',
						trigger: ['blur']
					},
				},
				carPoolRules:{
					'carPoolType': {
						type: 'string',
						required: true,
						message: '请选择类型',
						trigger: ['blur']
					},
					'departureLocation': {
						type: 'string',
						required: true,
						message: '请填写出发地',
						trigger: ['blur']
					},
					'destination': {
						type: 'string',
						required: true,
						message: '请填写目的地',
						trigger: ['blur']
					},
					'setOutTime': {
						type: 'string',
						required: true,
						message: '请选择出发时间',
						trigger: ['blur']
					},
					'setOutNum': {
						type: 'string',
						required: true,
						message: '请填写人数',
						trigger: ['blur']
					},
					'phoneNum': [{
						type: 'string',
						required: true,
						message: '请填写手机号码',
						trigger: ['blur']
					},{
						max:11,
						min:11,
						message: '请输入11位手机号',
						trigger: 'blur'
					}]
				}
			}
		},
		onShow() {
			if (!this.getIsLogin) { //*代表新增未完全				 
				//未登录
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
		},
		computed: {
			...mapGetters(['getNeedAuth', 'getIsLogin','getUserinfo'])
		},
		methods: {
			// 替换敏感词
			replaceSensitiveWords(text){
				const sensitiveWords = ['吸毒','色情','暴力']
				const regex = new RegExp(`(${sensitiveWords.join('|')})`, 'gi');		  
			    return text.replace(regex, (matchedText) => {
				  // 在此处添加自定义的替换字符串或者其他操作
				  console.log("发现了敏感词：" + matchedText);		    
				  // 返回替换结果（默认为空）
				  return '**';
			  });
			},
			// 选择发布类型
			selectClick(index) {
				console.log(index.name);
				this.keyword = index.name;
			},
			// 文件超出大小限制
			oversize() {
				uni.showToast({
					title: "图片最大不能超过2M",
					icon: 'none'
				})
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
					console.log(result);
				}
			},
			// 上传图片
			uploadFilePromise(url1) {
				return new Promise((resolve, reject) => {
					let a = uni.$u.http.upload('/common/appUploads', {
						params: {},
						/* 会加在url上 */
						// #ifdef APP-PLUS || H5
						// files: [], // 需要上传的文件列表。使用 files 时，filePath 和 name 不生效。App、H5（ 2.6.15+）
						// #endif
						filePath: url1, // 要上传文件资源的路径。
						// 注：如果局部custom与全局custom有同名属性，则后面的属性会覆盖前面的属性，相当于Object.assign(全局，局部)
						custom: {
							auth: true
						}, // 可以加一些自定义参数，在拦截器等地方使用。比如这里我加了一个auth，可在拦截器里拿到，如果true就传token
						name: 'files', // 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
						// #ifdef H5 || APP-PLUS
						timeout: 60000, // H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)
						// #endif
						// header: {},
						/* 会与全局header合并，如有同名属性，局部覆盖全局 */
						formData: {}, // HTTP 请求中其他额外的 form data
						// 返回当前请求的task, options。请勿在此处修改options。非必填
						getTask: (task, options) => {},
					}).then(res => {
						console.log("res：", res);
						// setTimeout(() => {
						resolve(res.data.data.fileNames)
						// }, 1000)
						// 返回的res.data 已经进行JSON.parse
					}).catch(err => {
						debugger
					})
				})
			},
			// 提交社会资讯
			submitSociety() {
				let imgs = ""
				for (var i = 0; i < this.fileList1.length; i++) {
					let item = this.fileList1[i]
					imgs += item.url + ","
				}
				this.$refs.uForm.validate().then(res => {
					const content =this.replaceSensitiveWords(this.societyData.content);
					submitSociety({
						newTitle: this.societyData.title,
						newContent: content,
						address: this.societyData.address,
						newTime: this.societyData.newTime,
						newPic: imgs
					}).then(res => {
						if(res.data.msg == '提交成功'){
							this.$refs.uToast.show({
								type:'success',
								message:'提交成功'
							})
							this.societyData = {
								brand_right: 0
							} // 清空表单
							this.societyData.content = ''
							this.fileList1 = ''
							setTimeout(function(){
								uni.switchTab({
									url:'/pages/index/index'
								})
							},1500)
						}else{
							this.$refs.uToast.show({
								type:'warning',
								message:'未知异常，请稍后重试'
							})
						}
					})
				}).catch(errors => {
					this.$refs.uToast.show({
						type:'warning',
						message:'请填写必填项'
					})
				})

			},
			
			// 提交求职
			submitJubHunt() {
				this.$refs.jobHuntForm.validate().then(res => {					
					submitJubHunt({
						username: this.jobHuntData.username,
						sex: this.jobHuntData.sexValue,
						phoneNum: this.jobHuntData.phoneNum,
						job: this.jobHuntData.job,
						jobStatus: this.jobHuntData.jobStatus,
						workLocation: this.jobHuntData.workLocation,
						salary: this.jobHuntData.salary,
						workExperience: this.jobHuntData.workExperience
					}).then(res => {
						this.$refs.uToast.show({
							type:'success',
							message:'提交成功'
						})
						this.jobHuntData = {
							brand_right: 0
						} // 清空表单
						this.jobHuntData.workExperience = ''
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1500)
					})

				}).catch(errors => {
					console.log(errors);
					this.$refs.uToast.show({
						type:'warning',
						message:'请填写必填项'
					})
				})
			},
			// 隐藏软键盘
			hideKeyboard() {
				uni.hideKeyboard()
			},
			// 社会资源--时间选择器关闭按钮
			showTimeClose() {
				this.showTime = false
				this.$refs.uForm.validateField('societyData.newTime')
			},
			// 社会资源 --时间选择器确定按钮
			showTimeConfirm(e) {
				this.showTime = false
				
				if(this.keyword == '社会资讯'){
					this.societyData.newTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
					this.$refs.uForm.validateField('societyData.newTime')
				}
				if(this.keyword == '拼车'){
					this.carPoolData.setOutTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
					this.$refs.carPoolForm.validateField('carPoolData.setOutTime')
				}
				if(this.keyword == '招聘'){
					this.recruitData.endTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
					this.$refs.recruitForm.validateField('recruitData.endTime')
				}
			},
			// 求职--性别选择返回值
			sexSelect(e) {
				this.jobHuntData.sex = e.name
				this.jobHuntData.sexValue = e.value
				this.$refs.jobHuntForm.validateField('jobHuntData.sex')
			},
			// 求职--状态选择返回值
			jobStatusSelect(e) {
				this.jobHuntData.jobStatus = e.name
				console.log(e.name);
				this.$refs.jobHuntForm.validateField('jobHuntData.jobStatus')
			},
			// 求职--办公区域选择返回值
			showAddressConfirm(e) {
				this.showAddress = false
				this.jobHuntData.workLocation = this.columns[0][e.indexs[0]]	
				this.$refs.jobHuntForm.validateField('jobHuntData.workLocation')
			},
			// 求职--办公区域选择 取消
			showAddressClose() {
				this.showAddress = false
				this.$refs.jobHuntForm.validateField('jobHuntData.workLocation')
			},
			// 招聘 --提交
			submitRecruit() {
				this.$refs.recruitForm.validate().then(res => {
					uni.$u.toast('提交成功')
					submitRecruit({
						recruitJob: this.recruitData.recruitJob,
						recruitSalary: this.recruitData.recruitSalary,
						peopleNum: this.recruitData.peopleNum,
						recruitAsk: this.recruitData.recruitAsk,
						workLocation: this.recruitData.workLocation,
						jobDescription: this.recruitData.jobDescription,
						recruitContacts: this.recruitData.recruitContacts,
						recruitmentUnit: this.recruitData.recruitmentUnit,
						telephone: this.recruitData.telephone
					}).then(res => {
						this.recruitData = {
							brand_right: 0
						} // 清空表单
						this.recruitData.recruitAsk = ''
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1500)
					})

				}).catch(errors => {
					console.log(errors);
					this.$refs.uToast.show({
						type:'warning',
						message:'请填写必填项'
					})
				})
			},
			// 房屋-------性质
			houseNatureSelect(e){
				this.showHouseNature = false
				this.houseSellData.houseNature = e.name	
				this.$refs.houseSellForm.validateField('houseSellData.houseNature')
			},
			// 房屋--类型
			houseMountSelect(e){
				this.showHouseToward= false
				this.houseSellData.houseMount = e.name	
				this.$refs.houseSellForm.validateField('houseSellData.houseMount')
			},
			// 房屋--朝向
			houseTowardSelect(e){
				this.showHouseToward = false
				this.houseSellData.houseToward = e.name	
				this.$refs.houseSellForm.validateField('houseSellData.houseToward')
			},
			// 提交--房屋租售
			submitHouse() {
				let imgs = ""
				for (var i = 0; i < this.fileList1.length; i++) {
					let item = this.fileList1[i]
					imgs += item.url + ","
				}
				console.log("99",this.houseSellData);
				this.$refs.houseSellForm.validate().then(res => {
					uni.$u.toast('校验通过')
					submitHouse({
						houseNature:this.houseSellData.houseNature,
						houseTitle:this.houseSellData.houseTitle,
						houseAddress:this.houseSellData.houseAddress,
						houseArea:this.houseSellData.houseArea,
						houseType: this.houseSellData.houseType,
						houseHeight:this.houseSellData.houseHeight,
						houseToward:this.houseSellData.houseToward,
						houseMount:this.houseSellData.houseMount,
						housePic:imgs.length>0?imgs:'/profile/upload/2023/08/20/picIsNull_20230820144758A001.png',
						housePrice:this.houseSellData.housePrice,
						contacts:this.houseSellData.contacts,
						telephone: this.houseSellData.telephone
					}).then(res => {
						this.houseSellData = {
							brand_right: 0
						} // 清空表单
						this.fileList1 = ''
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1500)
					})
				}).catch(errors => {
					console.log(errors);
					this.$refs.uToast.show({
						type:'warning',
						message:'请填写必填项'
					})
				})
			
			},
			// 周末游---提交
			submitWeekendTour(){
				let imgs = ""
				for (var i = 0; i < this.fileList1.length; i++) {
					let item = this.fileList1[i]
					imgs += item.url + ","
				}
				this.$refs.weekendTourForm.validate().then(res => {
					uni.$u.toast('校验通过')
					submitWeekendTour({
						title:this.weekendTourData.title,
						content:this.weekendTourData.content,
						address:this.weekendTourData.address,
						pic:imgs.length>0?imgs:'/profile/upload/2023/08/20/picIsNull_20230820144758A001.png',
					}).then(res => {
						this.weekendTourData = {
							brand_right: 0
						} // 清空表单
						this.weekendTourData.content=''
						this.fileList1 = ''
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1500)
					})
				}).catch(errors => {
					console.log(errors);
					this.$refs.uToast.show({
						type:'warning',
						message:'请填写必填项'
					})
				})
			},
			// 拼车 --类型
			carPoolTypeSelect(e){
				this.showCarPoolType= false
				this.carPoolData.carPoolType = e.name
				this.carPoolData.carPoolTypeValue = e.value
				this.$refs.carPoolForm.validateField('carPoolData.carPoolType')
			},
			// 拼车 --提交
			submitCarPool(){
				this.$refs.carPoolForm.validate().then(res=>{
					uni.$u.toast('校验通过')
					submitCarPool({
						departureLocation: this.carPoolData.departureLocation,
						destination: this.carPoolData.destination,
						carPoolType: this.carPoolData.carPoolTypeValue,
						setOutTime: this.carPoolData.setOutTime,
						setOutNum: this.carPoolData.setOutNum,
						phoneNum: this.carPoolData.phoneNum,
						remarks: this.carPoolData.remarks
					}).then(res=>{
						this.carPoolData = {
							brand_right: 0
						} // 清空表单
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1500)
					})
				}).catch(errors=>{
					console.log(errors);
					this.$refs.uToast.show({
						type:'warning',
						message:'请填写必填项'
					})
				})
			},
			// 点击复制
			copy() {
				uni.setClipboardData({
					data: this.phone,
					success: () => {
						uni.showToast({
							title: '复制成功',
							message: '复制成功',
							type: 'success'
						})
					}
				})
			}

		},
		onReady() {
			if(this.keyword){
				//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
				this.$refs.uForm.setRules(this.societyRules)
				this.$refs.jobHuntForm.setRules(this.jobHuntRules)	
			}
		}
	}
</script>

<style scoped lang="scss">

</style>